import R from '@common/type/response';
import type { NextApiResponse } from 'next';
import * as roleService from '@/common/service/sys_role';
import { AuthenticatedRequest, withAuth } from '@common/middleware/auth';

export async function handler(req: AuthenticatedRequest, res: NextApiResponse) {
  if (req.method === 'POST') {
    // 新增角色
    const id = await roleService.createRole(req.body);
    R.success(res,id);
  } else {
    res.status(405).json({ success: false, message: 'Method Not Allowed' });
  }
}

export default withAuth(handler); 